package f;

import f.f0.c;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import javax.annotation.Nullable;
import javax.net.ssl.SSLSocket;

/* compiled from: ConnectionSpec */
public final class h {
    public static final f[] e;
    public static final f[] f;
    public static final h g;
    public static final h h = new h(new a(false));
    public final boolean a;
    public final boolean b;
    @Nullable
    public final String[] c;
    @Nullable
    public final String[] d;

    /* compiled from: ConnectionSpec */
    public static final class a {
        public boolean a;
        @Nullable
        public String[] b;
        @Nullable
        public String[] c;
        public boolean d;

        public a(boolean z) {
            this.a = z;
        }

        public a a(String... strArr) {
            if (!this.a) {
                throw new IllegalStateException("no cipher suites for cleartext connections");
            } else if (strArr.length != 0) {
                this.b = (String[]) strArr.clone();
                return this;
            } else {
                throw new IllegalArgumentException("At least one cipher suite is required");
            }
        }

        public a b(f... fVarArr) {
            if (this.a) {
                String[] strArr = new String[fVarArr.length];
                for (int i = 0; i < fVarArr.length; i++) {
                    strArr[i] = fVarArr[i].a;
                }
                a(strArr);
                return this;
            }
            throw new IllegalStateException("no cipher suites for cleartext connections");
        }

        public a c(boolean z) {
            if (this.a) {
                this.d = z;
                return this;
            }
            throw new IllegalStateException("no TLS extensions for cleartext connections");
        }

        public a d(String... strArr) {
            if (!this.a) {
                throw new IllegalStateException("no TLS versions for cleartext connections");
            } else if (strArr.length != 0) {
                this.c = (String[]) strArr.clone();
                return this;
            } else {
                throw new IllegalArgumentException("At least one TLS version is required");
            }
        }

        public a e(e0... e0VarArr) {
            if (this.a) {
                String[] strArr = new String[e0VarArr.length];
                for (int i = 0; i < e0VarArr.length; i++) {
                    strArr[i] = e0VarArr[i].a;
                }
                d(strArr);
                return this;
            }
            throw new IllegalStateException("no TLS versions for cleartext connections");
        }
    }

    static {
        f[] fVarArr = new f[11];
        fVarArr[0] = f.q;
        fVarArr[1] = f.r;
        fVarArr[2] = f.s;
        fVarArr[3] = f.t;
        fVarArr[4] = f.u;
        fVarArr[5] = f.k;
        fVarArr[6] = f.m;
        fVarArr[7] = f.l;
        fVarArr[8] = f.n;
        fVarArr[9] = f.p;
        fVarArr[10] = f.o;
        e = fVarArr;
        f[] fVarArr2 = new f[]{r2, r4, r6, r8, r10, r12, r14, r16, r18, r20, r22, f.i, f.j, f.g, f.h, f.e, f.f, f.d};
        f = fVarArr2;
        a aVar = new a(true);
        aVar.b(fVarArr);
        r1 = new e0[2];
        e0 e0Var = e0.TLS_1_3;
        r1[0] = e0Var;
        e0 e0Var2 = e0.TLS_1_2;
        r1[1] = e0Var2;
        aVar.e(r1);
        aVar.c(true);
        a aVar2 = new a(true);
        aVar2.b(fVarArr2);
        e0[] e0VarArr = new e0[4];
        e0VarArr[0] = e0Var;
        e0VarArr[1] = e0Var2;
        e0VarArr[2] = e0.TLS_1_1;
        e0VarArr[3] = e0.TLS_1_0;
        aVar2.e(e0VarArr);
        aVar2.c(true);
        g = new h(aVar2);
        aVar2 = new a(true);
        aVar2.b(fVarArr2);
        aVar2.e(e0Var);
        aVar2.c(true);
    }

    public h(a aVar) {
        this.a = aVar.a;
        this.c = aVar.b;
        this.d = aVar.c;
        this.b = aVar.d;
    }

    public boolean a(SSLSocket sSLSocket) {
        if (!this.a) {
            return false;
        }
        String[] strArr = this.d;
        if (strArr != null && !c.u(c.p, strArr, sSLSocket.getEnabledProtocols())) {
            return false;
        }
        strArr = this.c;
        if (strArr == null || c.u(f.b, strArr, sSLSocket.getEnabledCipherSuites())) {
            return true;
        }
        return false;
    }

    public boolean equals(@Nullable Object obj) {
        if (!(obj instanceof h)) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        h hVar = (h) obj;
        boolean z = this.a;
        if (z != hVar.a) {
            return false;
        }
        return !z || (Arrays.equals(this.c, hVar.c) && Arrays.equals(this.d, hVar.d) && this.b == hVar.b);
    }

    public int hashCode() {
        return this.a ? ((((527 + Arrays.hashCode(this.c)) * 31) + Arrays.hashCode(this.d)) * 31) + (this.b ^ 1) : 17;
    }

    public String toString() {
        if (!this.a) {
            return "ConnectionSpec()";
        }
        String obj;
        String[] strArr = this.c;
        Object obj2 = null;
        String str = "[all enabled]";
        if (strArr != null) {
            Object unmodifiableList;
            if (strArr != null) {
                ArrayList arrayList = new ArrayList(strArr.length);
                for (String a : strArr) {
                    arrayList.add(f.a(a));
                }
                unmodifiableList = Collections.unmodifiableList(arrayList);
            } else {
                unmodifiableList = null;
            }
            obj = unmodifiableList.toString();
        } else {
            obj = str;
        }
        String[] strArr2 = this.d;
        if (strArr2 != null) {
            if (strArr2 != null) {
                ArrayList arrayList2 = new ArrayList(strArr2.length);
                for (String a2 : strArr2) {
                    arrayList2.add(e0.a(a2));
                }
                obj2 = Collections.unmodifiableList(arrayList2);
            }
            str = obj2.toString();
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("ConnectionSpec(cipherSuites=");
        stringBuilder.append(obj);
        stringBuilder.append(", tlsVersions=");
        stringBuilder.append(str);
        stringBuilder.append(", supportsTlsExtensions=");
        stringBuilder.append(this.b);
        stringBuilder.append(")");
        return stringBuilder.toString();
    }
}
